<h2><a href="javascript:;" class="button">添加分类</a></h2>
<div id="add_cate" style="display:none;">
<dl class="add">
	<form method="post" enctype="multipart/form-data">
	<input type="hidden" name="method" value="addcate">
	<dd>分类名称：<input type="text" name="name"></dd>
	<dd>简介：<input type="text" name="des"></dd>
	<dd>排序数字：<input type="text" name="ord" style="width:100px;"></dd>
	<dd>图片：<input type="file" name="techImg"></dd>
	<dd><input type="submit" style="cursor:pointer" value="添加"></dd>
	</form>
</dl>
</div>
<div style="clear:both;margin:5px;height:5px;"></div>
<table width="100%" border="0" cellpadding="0" cellspacing="2" class="list">
	<tr>
		<th width="10%">分类ID</th>
		<th width="20%">分类名称</th>
		<th width="40%">简介</th>
		<th width="10%">排序</th>
		<th width="20%"></th>
	</tr>
	{{foreach from=$rows key=key item=item name="est"}}
	<tr id="tr_{{$item.id}}" {{if $smarty.foreach.est.index%2 eq '0'}}class="even"{{/if}}>
		<td align="center">
			{{$item.id}}
		</td>
		<td align="center">
			<span class="cname"><font id="name_{{$item.id}}">{{$item.name}}</font>&nbsp;<img width="30" height="30" src="{{$item.techImg}}"/></span>
		</td>
		<td align="center"><font id="des_{{$item.id}}">{{$item.des}}</font></td>
		<td align="center"><font id="ord_{{$item.id}}">{{$item.ord}}</font></td>
		<td align="center">
			<input name="{{$item.id}}" class="editbtn" type="button" value="编辑">&nbsp;
			<input name="{{$item.id}}" class="delbtn" type="button" value="删除"></td>
	</tr>
	{{/foreach}}
</table>
<div id="bg" class="bg" style="display:none;"></div>
<div id="pop" class="pop" style="display:none;">
	<form method="post" enctype="multipart/form-data" name="popform">
	<input type="hidden" name="method" value="addcate">
	<input type="hidden" name="id" id="pop_id" value="">
	<ul>
		<li style="background-color:#330000; color: white; font-weight: bold;"><span><img id="popclose" src="/images/close.gif" title="关闭" style="width:30px;height:30px;cursor:pointer;"></span>快速修改</li>
		<li>分类名称：<input type="text" name="name" id="pop_name" value=""></li>
		<li>简介：<textarea cols="40" rows="10" name="des" id="pop_des"></textarea></li>
		<li>排序数字：<input type="text" name="ord" id="pop_ord" value="" style="width:100px;"></li>
		<li>图片：<input type="file" name="techImg"></li>
		<li>
			<input class="btn" type="button" value="保存" onclick="popsubmit('addcate')">
	</ul>
	</form>
</div>
<script>
	var type = "";
	$(document).ready(function(){
		
		$(".button").click(function(){
			$("#add_cate").toggle();
		})
		
		$(".sub_btn").each(function(){
			$(this).click(function(e){
				popShow($(this).attr("name"),e);
				type = "sub";
			})
		})
		
		$("#popclose").click(function(){
			popHide();
		})
		
		$(".editbtn").each(function(){
			$(this).click(function(e){
				popShow($(this).attr("name"),e);
				type = "";
			})
		})
	})
	
	function popHide(){
		$(".pop").hide();
		$(".bg").hide();
	}
	
	function popShow(id,e){
		$("#pop_id").val(id);
		$("#pop_name").val($("#name_"+id).html());
		$("#pop_des").val($("#des_"+id).html());
		$("#pop_ord").val($("#ord_"+id).html());
		center($(".pop"),$(".bg"),e);
	}
	
	function popsubmit(method)
	{
		if($("#pop_name").val() == ""){
			alert("请填写名称");return false;
		}
		if(method == "delcate"){
			if(!confirm("确认删除？"))return false;
		}

		document.popform.method.value = method;
		document.popform.submit();
	}
</script>